#ifndef DEFAULT_MODEL_
#define DEFAULT_MODEL_
#include"../process.h"
#include"distance_calc.h"
#include"model\language_model.h"
#include"model\translate_model.h"
#include"model\abbr_model.h"
#include"model\correction_model.h"

class DefaultModel{
	private:
		double cost[MAX_QUERYLENGTH];
		string cluster_id;
		map<string, int> frequency;
		map<string, int> query2freq;
		void co_occur(vector<string> &term_set, vector<string> &term_list, int cur, int start, int freq, map<string, int> &lm);
		void co_occur(string query, int freq, map<string, int> &lm);

		map<string, int> translate_freq;
		vector<vector<string>> groups;
		
		LanguageModel *lang_model;
		DistCalc *dist_calc;
		
		void parse_info(string cluster, map<string, int> &q2f, string &cid);
		void gen_language_model(map<string, int> &q2f, map<string, int> &lm);
		void raw_grouping(map<string, int> &q2f, vector<vector<string>> &gro, DistCalc *dist_calc);
		
		map<string, vector<pair<string, int>>> label2group;
		void elect_label(vector<vector<string>> &gro, map<string, int> &q2f, map<string, int> &lm, map<string, vector<pair<string, int>>> &l2g);	
		string raw_refine(string str, map<string, int> &lm, map<string, string> &w2c);
		
		TranslateModel *trans_model;
		void clear();
		string short_cut(map<string, vector<pair<string, int>>> &l2g);

		CorrectionModel *corr_model;
		map<string, int> c_label;

		AbbrModel *abbr_model;
		map<string, int> abbr_freq;
		pair<string, double> get_prob(vector<string> v, int s, int e);

	public:
		DefaultModel(DistCalc *dist_calc, LanguageModel *lang_model, TranslateModel *trans_model);
		DefaultModel(DistCalc *dist_calc, LanguageModel *lang_model, TranslateModel *trans_model, AbbrModel *abbr_model);
		DefaultModel(DistCalc *dist_calc, LanguageModel *lang_model, TranslateModel *trans_model, AbbrModel *abbr_model, CorrectionModel *corr_model);
		void build(string cluster);
		map<string, int> getTransModel();
		map<string, int> getLangModel();
		map<string, int> getAbbrModel();
		map<string, int> getLogSortCut();
		
};

#endif